package com.member.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.member.common.core.domain.model.LoginUser;
import com.member.common.enums.EnableStatusEnum;
import com.member.common.enums.ImportFailEnum;
import com.member.common.enums.OrderDeleteEnum;
import com.member.common.enums.SourceEnum;
import com.member.common.utils.DateUtils;
import com.member.common.utils.StringUtils;
import com.member.shop.domain.*;
import com.member.shop.dto.EvaluateTemplateDto;
import com.member.shop.mapper.SysBizCouponGrantUserMapper;
import com.member.shop.service.ISysBizCouponGrantUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Random;

import static com.member.common.utils.SecurityUtils.getLoginUser;

/**
 * 优惠券发放用户Service业务层处理
 *
 * @author lixinchen
 * @date 2024-05-08
 */
@Service
public class SysBizCouponGrantUserServiceImpl extends ServiceImpl<SysBizCouponGrantUserMapper, SysBizCouponGrantUser> implements ISysBizCouponGrantUserService {
    @Resource
    private SysBizCouponGrantUserMapper sysBizCouponGrantUserMapper;

    /**
     * 查询优惠券发放用户
     *
     * @param id 优惠券发放用户主键
     * @return 优惠券发放用户
     */
    @Override
    public SysBizCouponGrantUser selectSysBizCouponGrantUserById(Long id) {
        return sysBizCouponGrantUserMapper.selectById(id);
    }

    /**
     * 查询优惠券发放用户列表
     *
     * @param queryWrapper 优惠券发放用户
     * @return 优惠券发放用户
     */
    @Override
    public List<SysBizCouponGrantUser> selectSysBizCouponGrantUserList(LambdaQueryWrapper<SysBizCouponGrantUser> queryWrapper) {
        return sysBizCouponGrantUserMapper.selectList(queryWrapper);
    }

    /**
     * 新增优惠券发放用户
     *
     * @param sysBizCouponGrantUser 优惠券发放用户
     * @return 结果
     */
    @Override
    public int insertSysBizCouponGrantUser(SysBizCouponGrantUser sysBizCouponGrantUser) {
        sysBizCouponGrantUser.setCreateTime(DateUtils.getNowDate());
        return sysBizCouponGrantUserMapper.insert(sysBizCouponGrantUser);
    }

    /**
     * 修改优惠券发放用户
     *
     * @param sysBizCouponGrantUser 优惠券发放用户
     * @return 结果
     */
    @Override
    public int updateSysBizCouponGrantUser(SysBizCouponGrantUser sysBizCouponGrantUser) {
        sysBizCouponGrantUser.setUpdateTime(DateUtils.getNowDate());
        return sysBizCouponGrantUserMapper.updateById(sysBizCouponGrantUser);
    }

    /**
     * 批量删除优惠券发放用户
     *
     * @param ids 需要删除的优惠券发放用户主键
     * @return 结果
     */
    @Override
    public int deleteSysBizCouponGrantUserByIds(Long[] ids) {
        return sysBizCouponGrantUserMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除优惠券发放用户信息
     *
     * @param id 优惠券发放用户主键
     * @return 结果
     */
    @Override
    public int deleteSysBizCouponGrantUserById(Long id) {
        return sysBizCouponGrantUserMapper.deleteById(id);
    }

    @Override
    public List<SysBizCouponGrantUser> selectSysBizCouponGrantUserList(SysBizCouponGrantUser sysBizCouponGrantUser) {
        return sysBizCouponGrantUserMapper.selectSysBizCouponGrantUserList(sysBizCouponGrantUser);
    }

}
